package com.zpark;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zpark.pojo.User;
import com.zpark.service.UserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest
public class PageHaple {

    @Autowired
    private UserService userService;


    @Test
    public void page(){
        PageHelper.startPage(1, 5);
        List<User> users = userService.findAll();
        PageInfo<User> list = new PageInfo<>(users);
        System.out.println("当前页码"+list.getPageNum()+"页");
        System.out.println("当前页共有"+list.getPageSize()+"条数据");
        for (User user:users){
            System.out.println(user);
        }
    }
}
